package com.base.action;

import java.util.List;

import com.base.bean.Cardmaker;
import com.base.service.CardmakerService;
import com.base.service.DictService;
import com.common.bean.Datadict;
import com.common.util.PagerModel;
import com.common.util.StringToken;
import com.core.ssh2.AbstractActionSupport;
import com.opensymphony.xwork2.Preparable;

public class CardmakerManagerAction extends AbstractActionSupport implements Preparable{
	private static final long serialVersionUID = -293919531854859789L;

	private CardmakerService cardmakerService;
	
	private DictService dictService;
	
	private Cardmaker cardmaker;
	
	private long compno;
	
	private PagerModel pm;
	
	private List<Datadict> datadictlist;
	
	@SuppressWarnings("unchecked")
	public void prepare() throws Exception {
		String typecode = StringToken.DICT_CARD_COMPTYPE;
		datadictlist = dictService.findDictDetail(typecode);
	}
	
	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}
	
	public String goAddCardmaker() throws Exception {
		return SUCCESS;
	}
	
	public String addCardmaker() throws Exception {
		cardmakerService.addCardmaker(cardmaker);
		return SUCCESS;
	}
	
	public String findAllCardmaker() throws Exception {
		pm = cardmakerService.findCardmakerForPager();
		return SUCCESS;
	}
	
	public String findCardmaker() throws Exception {
		cardmaker = cardmakerService.findCardmaker(compno);
		return SUCCESS;
	}
	
	public String delCardmaker() throws Exception {
		cardmakerService.removeCardmaker(compno);
		return SUCCESS;
	}
	
	public String goUpdateCardmaker() throws Exception {
		cardmaker = cardmakerService.findCardmaker(compno);
		return SUCCESS;
	}
	
	public String updateCardmaker() throws Exception {
		cardmakerService.updateCardmaker(cardmaker);
		return SUCCESS;
	}

	/**
	 * @return the cardmaker
	 */
	public Cardmaker getCardmaker() {
		return cardmaker;
	}

	/**
	 * @param cardmaker the cardmaker to set
	 */
	public void setCardmaker(Cardmaker cardmaker) {
		this.cardmaker = cardmaker;
	}

	/**
	 * @return the cardmakerService
	 */
	public CardmakerService getCardmakerService() {
		return cardmakerService;
	}

	/**
	 * @param cardmakerService the cardmakerService to set
	 */
	public void setCardmakerService(CardmakerService cardmakerService) {
		this.cardmakerService = cardmakerService;
	}

	/**
	 * @return the compno
	 */
	public long getCompno() {
		return compno;
	}

	/**
	 * @param compno the compno to set
	 */
	public void setCompno(long compno) {
		this.compno = compno;
	}

	/**
	 * @return the pm
	 */
	public PagerModel getPm() {
		return pm;
	}

	/**
	 * @param pm the pm to set
	 */
	public void setPm(PagerModel pm) {
		this.pm = pm;
	}

	/**
	 * @return the datadictlist
	 */
	public List<Datadict> getDatadictlist() {
		return datadictlist;
	}

	/**
	 * @param datadictlist the datadictlist to set
	 */
	public void setDatadictlist(List<Datadict> datadictlist) {
		this.datadictlist = datadictlist;
	}

	/**
	 * @return the dictService
	 */
	public DictService getDictService() {
		return dictService;
	}

	/**
	 * @param dictService the dictService to set
	 */
	public void setDictService(DictService dictService) {
		this.dictService = dictService;
	}
	
}
